package com.example.customer.controller;

import com.example.customer.service.policyholderService;
import entity.policyholders_info;
import entity.sys_user_info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(methods = {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/policyholder")
public class policyholderController {
    @Autowired
    private policyholderService policyholderService;

    @ResponseBody
    @RequestMapping("/addPolicyholder.do")
    public int add(@RequestBody policyholders_info p){
        System.out.println(p.getSex());
        System.out.println(p.getAddress());
        System.out.println(p.getCredentials_number());
        System.out.println(p.getCredentials_type());
        System.out.println(p.getMob());
        System.out.println(p.getPolicyholders_name());
        System.out.println(p.getPolicyholders_number());

        return this.policyholderService.addPolicyholdersInfo(p);

    }

    @ResponseBody
    @RequestMapping("/delPolicyholder.do")
    public int del(Integer id) throws Exception {

        return this.policyholderService.delPolicyholdersInfo(id);
    }

    @RequestMapping("/getPolicyholder.do")
    public @ResponseBody policyholders_info get(Integer id) throws Exception{
        return this.policyholderService.getPolicyholdersInfo(id);
    }
    @ResponseBody
    @RequestMapping("/updatePolicyholder.do")
    public int updateUser(@RequestBody policyholders_info p)throws Exception{

        return this.policyholderService.upPolicyholdersInfo(p);

    }
}
